import axios from 'axios'
import { Indicator } from 'mint-ui'

const ajax = axios.create({})

ajax.interceptors.request.use((config) => {
  Indicator.open('Loading...')
  return config
})

ajax.interceptors.response.use((resp) => {
  Indicator.close()
  return resp
})

// 首页的数据
export const getHome = () => {
  return ajax.get('/api/tab/1?start=0')
}
// 获取分类菜单
export const getCateNav = () => {
  return ajax.get('/api/tabs?sa=')
}
// 获取商品列表
export const getProductList = (tabid, start = 0) => {
  return ajax.get(`/api/tab/${tabid}?start=${start}`)
}

// 商品详情
export const getProductDetail = (id) => {
  return ajax.get(`/api/detail?id=${id}&normal=1&sa=`)
}

// 登陆
export const postLogin = (loginInfo) => {
  return ajax.post('/app/mock/163597/login', loginInfo)
}
